<?php

/**
 * @var $form CActiveForm
 * @var $model RegisterClassForm
 */
?>
<div class="form" id="jobDialogForm">
    <?php if(Yii::app()->user->isGuest){ ?>
    <div class="flash-notice">Bạn nên <?php echo CHtml::link("Đăng nhập",Yii::app()->createUrl('site/login')); ?> trước khi đăng ký học.</div>
        <?php }else{ ?>
    <div class="flash-notice">Điền đầy đủ các nội dung bên dưới.</div>
        <?php } ?>
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'register-class-form',
        'enableAjaxValidation' => true,
    )); ?>
    <?php //echo $form->errorSummary($model); ?>
    <table>
        <tr class="row">
            <td><?php echo $form->labelEx($model, 'name'); ?></td>
            <td><?php echo $form->textField($model, 'name', array('size' => 20, 'maxlength' => 150, 'disabled' => !Yii::app()->user->isGuest)); ?>
                <?php echo $form->error($model, 'name'); ?></td>
        </tr>
        <tr class="row">
            <td><?php echo $form->labelEx($model, 'username'); ?></td>
            <td><?php echo $form->textField($model, 'username', array('size' => 20, 'maxlength' => 150, 'disabled' => !Yii::app()->user->isGuest)); ?>
                <?php echo $form->error($model, 'username'); ?>
                            </td>
        </tr>
        <tr class="row">
            <td> <?php echo $form->labelEx($model, 'birthday'); ?></td>
            <td><?php echo $form->textField($model, 'birthday', array('size' => 20, 'maxlength' => 150));
                /*$this->widget('zii.widgets.jui.CJuiDatePicker', array(
                    'name' => 'RegisterClassForm[birthday]',
                    'language' => 'vi',
                    'value' => '',//$model->birthday ? date('d/m/Y',$model->birthday) : 
                    // additional javascript options for the date picker plugin
                    'options' => array(
                        'showAnim' => 'fold',
                        'changeMonth' => true,
                        'changeYear' => true
                    ),
                ));*/
                ?>
                <p class="hint">Ví dụ: 31/02/1995</p>
                <?php echo $form->error($model, 'birthday'); ?>
            </td>
        </tr>
        <tr class="row">
            <td><?php echo $form->labelEx($model, 'email'); ?></td>
            <td><?php echo $form->textField($model, 'email', array('size' => 20, 'maxlength' => 150, 'disabled' => !Yii::app()->user->isGuest)); ?>
                <?php echo $form->error($model, 'email'); ?></td>
        </tr>
        <tr class="row">
            <td><?php echo $form->labelEx($model, 'tel'); ?></td>
            <td><?php echo $form->textField($model, 'tel', array('size' => 20, 'maxlength' => 150)); ?>
                <?php echo $form->error($model, 'tel'); ?></td>


        </tr>
        <tr class="row">
            <td><?php echo $form->hiddenField($model, 'cid');?></td>
        </tr>
        <?php if (CCaptcha::checkRequirements()): ?>
        <tr>
            <td colspan="2"><?php echo $form->labelEx($model, 'verifyCode'); ?></td>
        </tr>
        <tr>
            <td colspan="2"><?php $this->widget('CCaptcha',array('buttonLabel'=>'Lấy mã khác')); ?></td>
        </tr>
        <tr>
            <td colspan="2"><?php echo $form->textField($model, 'verifyCode'); ?><?php echo $form->error($model, 'verifyCode'); ?></td>
        </tr>
        <?php endif; ?>
        <tr>
            <td>
                <?php echo CHtml::ajaxSubmitButton('Đăng ký', '', array('success'=>'js:function(data){

                    if(data.ok){
                        alert("Bạn đã đăng ký thành công!");
                        var remove = function () {
                                            $(this).remove();
                                        };

                        $("#dxt-mask").fadeOut(remove);
                        $("#dxt-box").fadeOut(remove);
                        window.location.reload();
                    }
                }','beforeSend'=>'js:function(){
                    //alert($(this).attr("disabled"));
                    $(this).attr("disabled", true);

                }'));?>
            </td>
        </tr>
    </table>
    <?php $this->endWidget(); ?>

</div>
